<?php

/**
 * Category form.
 *
 * @package    lomejorde
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CategoryForm extends BaseCategoryForm
{
    public function configure()
    {
        unset($this['updated_at'], $this['created_at'], $this['slug'], $this['candidates_list']);
        
        $this->setWidget('description', new sfWidgetFormTextarea(array(),array('rows' => 2, 'cols' => 50)));

        $this->setWidget('image', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->image,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));

        $this->setValidator('image', new sfValidatorFile(array(
            'mime_types' => 'web_images',
            'path' => sfConfig::get('sf_upload_dir'),
            'required' => false,
        )));
        
        $this->setWidget('image', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->image,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));

        $this->setValidator('background', new sfValidatorFile(array(
            'mime_types' => 'web_images',
            'path' => sfConfig::get('sf_upload_dir'),
            'required' => false,
        )));
        
        $this->setWidget('background', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->background,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));

        $this->setWidget('thumb1', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->thumb1,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));

        $this->setValidator('thumb1', new sfValidatorFile(array(
            'mime_types' => 'web_images',
            'path' => sfConfig::get('sf_upload_dir'),
            'required' => false,
        )));
        
        $this->setWidget('thumb2', new sfWidgetFormInputFileEditable(array(
            'file_src'    => '/uploads/'.$this->getObject()->thumb2,
            'edit_mode'   => !$this->isNew(),
            'is_image'    => true,
            'with_delete' => false,
        )));

        $this->setValidator('thumb2', new sfValidatorFile(array(
            'mime_types' => 'web_images',
            'path' => sfConfig::get('sf_upload_dir'),
            'required' => false,
        )));
        
        $this->widgetSchema->setLabels(array(
            'name' => 'Nombre',
            'description' => 'Descripción',
            'image' => 'Imagen',
            'background' => 'Fondo',
            'thumb1' => 'Thumbnail B/N',
            'thumb2' => 'Thumbnail Color',
        ));
    }
}
